package com.example.hms.controller;

import com.example.hms.service.UserService;
import com.example.hms.util.Result;
import com.example.hms.util.ResultSubmit;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

//集两条注解为一身的注解
@RestController
//标识路径注解
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public Result login(@RequestBody Map<String,String> map, HttpServletRequest request){
        String userId=map.get("userId");
        String userPassword=map.get("userPassword");
        if (userId==null || userId.isEmpty() || userPassword == null || userPassword.equals("")){
            return ResultSubmit.error("登录失败，参数不全");
        }
        return userService.login(userId,userPassword,request);
    }
}
